t = {}

local fullscreenImageWidth = 570
local fullscreenImageHeight = 427.5

local nonfsImageWidth = 480
local nonfsImageHeight = 360


t.loadImage = function(imagename, width, height)
	if width == 0 or height == 0 then print("loadImage: width or height zero") end
	return display.newImageRect("images/"..imagename, width/2048*fullscreenImageWidth, height/1536*fullscreenImageHeight)
end

t.loadImageOpt = function(imagename, options)

	local screenW = nonfsImageWidth
	local screenH = nonfsImageHeight
	if options.stretch == nil then
		options.stretch = false
	elseif options.stretch then
		screenW = fullscreenImageWidth
		screenH = fullscreenImageHeight
	end

	local image = display.newImageRect("images/"..imagename, options.w/2048*screenW, options.h/1536*screenH)
	image.xScale=options.scale or 1
	image.yScale=options.scale or 1
	image.alpha = options.alpha or 1
	image.x = options.x or 0
	image.y = options.y or 0
	return image
end

t.createAnim = function(imagename, x,y, sheetData, sequenceData)

	sheetData.width = sheetData.width / 2048 * fullscreenImageWidth
	sheetData.height = sheetData.height / 1536 * fullscreenImageHeight
  sheetData.sheetContentWidth = sheetData.sheetContentWidth / 2048 * fullscreenImageWidth
  sheetData.sheetContentHeight = sheetData.sheetContentHeight / 2048 * fullscreenImageWidth
	local mySheet = graphics.newImageSheet("images/"..imagename, sheetData)
	local animation = display.newSprite(mySheet, sequenceData)
	animation.x = x
	animation.y = y
	return animation
end

t.printTable = function(table)
	for key,value in pairs(table) do
		print(key,value)
	end
end

t.timerCancel = function(tt)
	if tt then timer.cancel(tt) end
end

t.transitionCancel = function(tn)
	if tn then transition.cancel(tn) end
end

t.destroy = function(o)
	if o then
		o:removeSelf()
		o = nil
	end
end

--[[ show overlay code
		local options =
		{
			effect = "fade",
			time = 400,
			isModal = false
--			params = { sample_var=456 }
		}
		storyboard.showOverlay("scripts.inventory", options)
]]--
		
--		storyboard.hideOverlay("zoomInOutFade", 400) -- hide overlay


 --[[ mask test f4c2
  local door = display.newImageRect("images/door.png", 512,512)
  door.x = 51
  door.y = -78
  door.xScale = 0.28
  door.yScale = 0.25
  local mask = graphics.newMask("images/doormask.png")
  local layer = common.room:getLayer(1)
  --layer:setMask(mask)
  --layer.maskX = layer.contentWidth/2
  --door.maskX = layer.contentWidth * 2
--door.maskY = door.contentHeight*0.5
  door:setMask(mask)
  door.maskX = -20
  
  transition.to(door, {time=3000,x=door.x - 75, maskX = 250})
  common.room:addLayerObject(1, door)
  ]]--
return t